﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TRPOP.CMS.Web.UI;

using TRPOP.Common;

namespace TRPOP.CMS.Web.Admin
{
    public partial class syserrorlog : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.SystemManage_Other;
        }
        #endregion

        #region 页面变量
        int m_intRecordCount = 0;
        private TRPOP.CMS.Business.LogManage oLogManage = new TRPOP.CMS.Business.LogManage();
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            Pager.PageChanged += new EventHandler(Pager_Change);
            if (!IsPostBack)
            {
                LoadBase();
                BindData();
            }
        }
        protected void Pager_Change(object sender, EventArgs e)
        {
            BindData();
        }
        //查询
        protected void btSearch_Click(object sender, EventArgs e)
        {
            Pager.CurrentPage = 1;
            BindData();
        }
        //删除
        protected void btSubmit_Click(object sender, EventArgs e)
        {
            EnumSubmitResult oesrResult = EnumSubmitResult.Failed;
            string ids = TRPOP.Common.RequestHelper.RequestString("delid");
            if (ids.Length > 0)
            {
                oesrResult = oLogManage.DeleteInfoByIds(ids);
                switch (oesrResult)
                {
                    case EnumSubmitResult.Success:
                        Alert("信息删除成功。");
                        break;
                    default:
                        Alert("信息删除失败。");
                        break;
                }
                BindData();
            }
            else
            {
                Alert("没有选中任何要删除的信息");
                return;
            }
        }
        #endregion

        #region 页面方法
        void LoadBase()
        { 
        
        }

        void BindData()
        {
            string strCondition = "";
            if ((txtBeginTime.Text).ToDateTime() != StringExtension.NullDateTime)
            {
                strCondition += " And [AddTime]>='" + (txtBeginTime.Text) + "'";
            }

            if ((txtEndTime.Text).ToDateTime() != StringExtension.NullDateTime)
            {
                strCondition += " And [AddTime]<='" + (txtEndTime.Text) + "'";
            }

            rptList.DataSource = oLogManage.GetListByPager(Pager.CurrentPage, Pager.PageSize, strCondition, " LogId DESC", out m_intRecordCount);
            rptList.DataBind();
            Pager.RecordCount = m_intRecordCount;
        }
        #endregion
    }
}